import java.net.*;
import java.util.ArrayList;

//Userobjekt wird in Userdatenbank (UserDB) gespeichert.
//Inhalt: Userinformationen, zwischengespeicherter Notifications
public class User {
	private String name;
	private InetAddress ip;
	private boolean loggedin=false;
	private int port;
	private ArrayList<String> notifications =null;
	
	public User (String name){
		this.name=name;
		notifications = new ArrayList<String>();	
	}
	public boolean isLoggedin() {
		return loggedin;
	}
	public void setLoggedin(boolean loggedin) {
		this.loggedin = loggedin;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setIP(InetAddress ip){
		this.ip = ip;
	}
	public InetAddress getIP(){
		return ip;
	}
	public void setPort(int port){
		this.port=port;
	}
	public int getPort(){
		return this.port;
	}
	public void addNotifications(String message){
		//Notification wird gespeichert wenn User nicht eingelogged ist oder "none" heisst
		if(!(name.equals("none"))){
			notifications.add(message);
		}
	}
	public void sendNotifications(){
		//Sende alle gespeicherten Notifications
		for(int i=0;i<notifications.size();i++){
			new Notification(getPort(),notifications.get(i),getIP());
		}
		//Loesche bereits gesendete Notifications
		notifications = new ArrayList<String>();
	}
	//Sendet Nachricht wenn Server heruntergefahren wird
	
			
	

}
